<template>
	<view class="bgImg">
		<view class="InfoBox">
			<view class="threshold">
			<!-- 	<view class="Range">
				<image :src="info.voucher_t_customimg" mode=""></image>
				</view> -->
				<view class="Range" v-if="info.voucher_t_range==0">通用优惠券</view>
				<view class="Range" v-if="info.voucher_t_range==1"> 商品优惠券</view>
				<view class="Range" v-if="info.voucher_t_range==2">分类优惠券</view>
				<view class="money"><span>￥</span>{{info.voucher_price||info.voucher_t_price}}代金券</view>
				<view class="money_ry" > 满{{info.voucher_limit||info.voucher_t_limit}}元使用</view>
			</view>
			<view class="category">
				<view class="classification" v-if="info.voucher_t_range==2">范围：{{info.gc_name}}</view>
				<view class="classification" v-if="info.voucher_t_range==0">范围： 全场通用</view>
				<view class="Time">日期:<span> {{info.start_date}}至{{info.end_date}}</span></view>
			</view>
			<view class="Btn" @click="Touse()">立即使用</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				voucher_id:"",
				info:"",
				type:''
				
			}
		},
		onLoad(e) {
			if(e.voucher_id){
				this.voucher_id=e.voucher_id
			}
			if(e.type){
				this.type = e.type
			}
			this.GetInfo()
		},
		methods: {
			Touse(){
				var that=this	
				if(this.info.voucher_t_range==0){
					if(this.info.store_id){
						uni.navigateTo({
							url:"/mall/store/store?store_id="+this.info.store_id
						})
					}else{
						uni.switchTab({
							url:"/main/home/index"
						})
					}
					
				}else if(this.info.voucher_t_range==1){//商品
					if(this.info.is_more_goods==1){
						uni.navigateTo({
							url:'/operation/voucher/productsLists?voucher_t_id='+this.info.voucher_t_id
						})
					}else{
						if(this.info.voucher_t_rangeid){
							uni.navigateTo({
								url:"/mall/goods/info?goods_id="+this.info.voucher_t_rangeid.split(",")[0]
							})
						}
					}
					

				}else if(this.info.voucher_t_range==2){//分类
					uni.navigateTo({
						url:"/mall/goods/list?thirdid="+this.info.voucher_t_rangeid+"&index="+this.info.gc_name
					})
				}
				
			},
			GetInfo(){
				if(this.type == 1){
					this.$util.request({
						url:'/mobile/index.php?act=goods&op=voucher_info',
						method:'get',
						data:{
							voucher_t_id:this.voucher_id
						}
					}).then((res)=>{	
						if(res.error_code==0){
							this.info=res.datas.info
						}else{
							uni.showToast({
								title:res.message,
								icon:"none"
							})
						}
					})
				}else{
				this.$util.request({
					url:'/mobile/index.php?act=member_voucher&op=view',
					method:'get',
					data:{
						voucher_id:this.voucher_id
					}
				}).then((res)=>{	
					if(res.error_code==0){
						this.info=res.datas.info
					}else{
						uni.showToast({
							title:res.message,
							icon:"none"
						})
					}
				})
				}
			}
		}
	}
</script>

<style>
	.Btn{
		width: 500rpx;
		height: 92rpx;
		background: linear-gradient(140deg, #EA8C1E 0%, #E84A1D 100%);
		border-radius: 50rpx 50rpx 50rpx 50rpx;
		font-size: 32rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #FFFFFF;
		text-align: center;
		line-height: 92rpx;
		margin:68rpx auto 0;
	}
	.category{
		font-size: 28rpx;
		color: #333333;
	}
	.money{
		font-size: 80rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #E96A1D;
		line-height: 60rpx;
	}
	.money span{
		font-size: 40rpx;
	}
	.money_ry{
		font-size: 30rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #323232;
		margin-bottom:147rpx;
	}
	.Range{
		/* font-size: 32rpx; */
		color: #333;
		text-align: left;
		margin-bottom: 82rpx;
		display: flex;
		align-items: center;
	}
	.Range image{
		width: 38rpx;
		height: 38rpx;
	}
	.threshold{
		text-align: center;
		font-size: 28rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #323232;
	}
	.InfoBox{
		/* height: 350rpx; */
		padding:30rpx 60rpx 50rpx;
		/* text-align: center; */
		/* border-bottom: 1rpx dashed #000000; */
		width: 570rpx;
		height: 690rpx;
		background: url('/static/images/daijinbg.png') no-repeat left top;
		background-size: 100% 100%;
		margin: 30rpx;
	}
	
	.bgImg{
		/* background-image:url("../static/images/carsDbg.png"); */
		width: 100%;
		min-height: 94vh;
		background-size: 100% 100%;
		position: relative;
	}
	.Time span{
		color: #E96A1D;
	}
</style>
